package com.jai.pms.message.controller;

import com.jai.pms.message.listener.RedisStreamListener;
import com.ruoyi.common.redis.service.RedisService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.stream.RecordId;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/index")
public class index {
    private static final Logger logger = LoggerFactory.getLogger(RedisStreamListener.class);

    @Autowired
    private RedisService redisService;

    @GetMapping("/login")
    public String login(){
        Map<String, Object> map = new HashMap<>();
        map.put("service", "shot");
        map.put("method", "add");
        map.put("id", 12);
        RecordId recordId = redisService.addMessage(map);
        logger.info("发送到shot任务：{}", recordId);
        return recordId.toString();
    }

    @GetMapping("/login2")
    public String login2(){
        Map<String, Object> map = new HashMap<>();
        map.put("service", "scene");
        map.put("method", "del");
        map.put("id", 9);
        RecordId recordId = redisService.addMessage(map);
        logger.info("发送到scene任务：{}", recordId);
        return recordId.toString();
    }
}